package com.music.service.folders.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.music.service.folders.beans.Folder;
import com.music.service.folders.constants.FolderState;

public class FolderMapper  implements RowMapper {

	public Object mapRow(ResultSet pResultSet, int pArg1) throws SQLException {
		Folder folder = new Folder();
		folder.setFolderId(pResultSet.getLong("folder_id"));
		folder.setFolderName(pResultSet.getString("folder_name"));
		folder.setOwnerId(pResultSet.getLong("created_member_id"));
		folder.setLastAddedAlbumId(pResultSet.getLong("last_added_album_id"));
		folder.setCreationDate(pResultSet.getDate("creation_date"));
		folder.setLastUpdateDate(pResultSet.getDate("last_update_date"));
		// For MySql, retrieve state as string.
		folder.setState(FolderState.getFolderState(pResultSet.getString("state")));
		return folder;
	}

}
